/**
 * 菜单相关请求模块
 */

import request from '@/utils/request'

export const createOrUpdateMenu = (data) => {
  return request({
    method: 'POST',
    url: '/api/Permission/Post',
    data
  })
}

export const getEditMenuInfo = (id = -1) => {
  return request({
    method: 'GET',
    url: `/api/Permission/Get/${id}`
  })
}

export const getAllMenus = (params) => {
  return request({
    method: 'GET',
    url: '/api/Permission/Get',
    params: params
  })
}

export const deleteMenu = (id) => {
  return request({
    method: 'DELETE',
    url: '/api/Permission/Delete',
    params: id
  })
}

export const getMenuNodeList = () => {
  return request({
    method: 'GET',
    url: '/boss/menu/getMenuNodeList'
  })
}

export const allocateRoleMenus = (data) => {
  return request({
    method: 'POST',
    url: '/boss/menu/allocateRoleMenus',
    data
  })
}

export const getRoleMenus = (roleId) => {
  return request({
    method: 'GET',
    url: '/boss/menu/getRoleMenus',
    params: { // axios 会把 params 转换为 key=value&key=value 的数据格式放到 url 后面(以?分割)
      roleId
    }
  })
}
